//
//  LSZPoorHouseholdViewController.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/10/27.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZPoorHouseholdViewController.h"

@interface LSZPoorHouseholdViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong) UITableView * tableViewPoor;
@property(nonatomic,strong) NSArray * arrayTitle;
@end

@implementation LSZPoorHouseholdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"贫困户管理";
    self.tableViewPoor.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.tableViewPoor registerClass:[LSZPoorHouseholdTableViewCell class] forCellReuseIdentifier:@"LSZPoorHouseholdTableViewCell"];
    self.arrayTitle = @[@"户主姓名",@"贫困属性",@"致贫原因",@"所在地",@"帮扶措施"];
//    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"添加"] style:UIBarButtonItemStylePlain target:self action:@selector(clickPoorHousehold)];
//    self.navigationItem.rightBarButtonItem = rightBarItem;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.inquiryPoorHouseholdsManager.mutArrayData.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0.001;
    }else{
        return 10;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZPoorHouseholdTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZPoorHouseholdTableViewCell" forIndexPath:indexPath];
    if (self.inquiryPoorHouseholdsManager.mutArrayData.count > indexPath.section) {
        cell.labelStyle.text = self.arrayTitle[indexPath.row];
        LSZInquiryPoorHouseholdsMg *  inquiryPoorHouseholdsMg = nil;
        inquiryPoorHouseholdsMg = self.inquiryPoorHouseholdsManager.mutArrayData[indexPath.section];
        if(indexPath.row == 0){
            cell.labelTitle.text = inquiryPoorHouseholdsMg.name;
            cell.labState.hidden = NO;
            cell.labState.text = inquiryPoorHouseholdsMg.attribute;
        }else if (indexPath.row == 1){
            cell.labState.hidden = YES;
            cell.labelTitle.text = inquiryPoorHouseholdsMg.povertyStatus;
        }else if (indexPath.row == 2){
            cell.labState.hidden = YES;
            cell.labelTitle.text = inquiryPoorHouseholdsMg.povertyReason;
        }else if (indexPath.row == 3){
            cell.labState.hidden = YES;
            cell.labelTitle.text = inquiryPoorHouseholdsMg.branchName;
        }else{
            cell.labState.hidden = YES;
            cell.labelTitle.text = inquiryPoorHouseholdsMg.attribute;
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.inquiryPoorHouseholdsManager.mutArrayData.count > indexPath.section) {
        LSZInquiryPoorHouseholdsMg *  inquiryPoorHouseholdsMg = nil;
        inquiryPoorHouseholdsMg = self.inquiryPoorHouseholdsManager.mutArrayData[indexPath.section];
        LSZInformationPoorHouseholdsVC * vc = [[LSZInformationPoorHouseholdsVC alloc]init];
        vc.inquiryPoorHouseholdsMg = inquiryPoorHouseholdsMg;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(void)clickPoorHousehold
{
    LSZAddedIndustryManagementVC * VC = [[LSZAddedIndustryManagementVC alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}
-(UITableView *)tableViewPoor
{
    if (_tableViewPoor == nil) {
        _tableViewPoor = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height) style:UITableViewStylePlain];
        _tableViewPoor.delegate = self;
        _tableViewPoor.dataSource = self;
        _tableViewPoor.estimatedRowHeight=0;
        _tableViewPoor.estimatedSectionFooterHeight =0;
        _tableViewPoor.estimatedSectionHeaderHeight =0;
        [_tableViewPoor setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        [self.view addSubview:_tableViewPoor];
    }
    return _tableViewPoor;
}

@end
